package com.bagdemir.registration.validator;


import org.apache.commons.lang.StringUtils;
import org.springframework.validation.Errors;
import org.springframework.validation.Validator;

import com.bagdemir.registration.beans.CustomerData;

public class RegistrationFormValidator implements Validator {
	 
	public boolean supports(Class clazz) {
		return clazz.getName().equals(CustomerData.class.getName()) ? true : false;
	}
 
	public void validate(Object object, Errors errors) {
		//TODO your validation logic.
                /* object is your form object. */
		CustomerData custData = (CustomerData) object;
                /* an example validation for name field */
		if (StringUtils.isBlank(custData.getName()))
			errors.rejectValue("name", "name.required", "name is required");
	}
}
